import cv2
import numpy as np
img = np.zeros((400, 640, 3), dtype=np.uint8)+255

def draw(event, x, y, flag, param):
    if event == cv2.EVENT_LBUTTONDBLCLK:
        cv2.circle(img, (x, y), 20, (255, 0, 0), -1)
    elif event == cv2.EVENT_RBUTTONDOWN:
        cv2.rectangle(img, (x, y), (x + 20, y + 20), (0, 0, 255), -1)

cv2.namedWindow("test")
cv2.setMouseCallback("test", draw)
while True:
    cv2.imshow("test", img)
    key = cv2.waitKey(1)
    if key == 27:
        break
cv2.destroyAllWindows()